package s14.ch17.ex1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

public class MyClient {

	public static void main(String[] args) throws UnknownHostException, IOException {

		Socket client = new Socket(InetAddress.getLocalHost(), 1234);
	
		BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
		PrintWriter pw = new PrintWriter(client.getOutputStream(), true);
		
		String message = "Greg";
		pw.println("Hello " + message);
		message = br.readLine();
		pw.println("Hello " + message);
		message = br.readLine();
		
		System.out.println(message);
		
		client.close();		
	}
}
